package xyz.syyrjx.blog.entity.ai.chat;

import com.fasterxml.jackson.core.JsonProcessingException;
import xyz.syyrjx.blog.util.ConstValuePool;

/**
 * @author 大地崩坏苍蝇兽
 * @date 2024/2/18 16:13
 * @description ...
 * @since v0.0.1
 */
public class ChatMessage {
    // 角色
    private String role;
    // 消息内容
    private String content;

    public ChatMessage() {
    }

    public ChatMessage(String role, String content) {
        this.role = role;
        this.content = content;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        try {
            return ConstValuePool.OBJECT_MAPPER.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }

    public static ChatMessage createUserDialogue(String content) {
        return new ChatMessage("user", content);
    }

    public static ChatMessage createAssistantDialogue(String content) {
        return new ChatMessage("assistant", content);
    }
    public static ChatMessage createSystemDialogue(String content) {
        return new ChatMessage("system", content);
    }
}
